<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" 
  xmlns:jdbc="http://www.springframework.org/schema/jdbc"
  xmlns:tx = "http://www.springframework.org/schema/tx"
  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="
        http://www.springframework.org/schema/beans  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
        http://www.springframework.org/schema/jdbc   http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
        http://www.springframework.org/schema/tx     http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
        ">

  <!-- main configuration, loaded via factory bean -->
  <bean id="jdbcConfigProperties" 
    class="org.geoserver.jdbcconfig.internal.JDBCConfigPropertiesFactoryBean">
      <constructor-arg ref="resourceStore"/>
  </bean>

  <!-- data source, also loaded and configured via factory bean -->
  <bean id="jdbcConfigDataSource" class="org.geoserver.jdbcloader.DataSourceFactoryBean">
    <constructor-arg ref="jdbcConfigProperties" />
  </bean>

  <!-- transaction manager -->
  <bean id="jdbcConfigTransactionManager"
  	class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
    <property name="dataSource" ref="jdbcConfigDataSource" />
  </bean>

  <tx:annotation-driven />

  <bean id="jdbcPersistenceBinding" class="org.geoserver.jdbcconfig.internal.XStreamInfoSerialBinding">
    <constructor-arg ref="xstreamPersisterFactory" />
  </bean>

  <bean id="JDBCConfigDB" class="org.geoserver.jdbcconfig.internal.ConfigDatabase">
    <constructor-arg ref="jdbcConfigProperties" />
    <constructor-arg ref="jdbcConfigDataSource" />
    <constructor-arg ref="jdbcPersistenceBinding" />
  </bean>

  <bean id="JDBCCatalogFacade" class="org.geoserver.jdbcconfig.catalog.JDBCCatalogFacade">
    <constructor-arg ref="JDBCConfigDB" />
  </bean>

  <bean id="JDBCGeoServerFacade" class="org.geoserver.jdbcconfig.config.JDBCGeoServerFacade">
    <constructor-arg ref="JDBCConfigDB" />
    <property name="resourceLoader" ref="resourceLoader" />
    <property name="ddResourceStore" ref="dataDirectoryResourceStore" />
  </bean>

  <bean id="JDBCGeoServerLoader" class="org.geoserver.jdbcconfig.JDBCGeoServerLoader">
    <description>
      Replaces the default GeoServerLoader to establish the JDBCCatalogFacade and JDBCGeoServerFacade
    </description>
    <constructor-arg ref="resourceLoader" />
    <constructor-arg ref="jdbcConfigProperties" />
    <property name="catalogFacade" ref="JDBCCatalogFacade" />
    <property name="geoServerFacade" ref="JDBCGeoServerFacade" />
  </bean>
  
  <bean id="JDBCConfigStatusProvider" class="org.geoserver.jdbcconfig.web.JDBCConfigStatusProvider">
    <constructor-arg ref="jdbcConfigProperties" />
  </bean>
  
  <bean id="JDBCCacheProvider" class="org.geoserver.jdbcconfig.internal.JDBCCacheProvider"/>
    <bean id="JDBCConfigXStreamPersisterInitializer" class="org.geoserver.jdbcconfig.internal.JDBCConfigXStreamPersisterInitializer"/>

  <bean id="JDBCLifecycleHandler" class="org.geoserver.jdbcconfig.internal.JDBCLifecycleHandler">
    <constructor-arg ref="JDBCConfigDB"/>
  </bean>
</beans>
